package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.entity.Complaints;
import com.s3.khospitalds.service.ComplaintsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hlq
 * @version 1.0
 * @Description
 * @date 2025/3/4 14:50
 */
@RestController
@CrossOrigin(origins = "*")
public class ComplaintsController {
    @Autowired
    private ComplaintsService complaintsService;
    //查询全部投诉信息
    @RequestMapping("/AllCopts")
    public R getAllComplaints(){
        return new R().addData("AllCopts",complaintsService.list());
    }
    //新增投诉信息
    @PostMapping("/insertCopts")
    public R insertComplaints(@RequestBody Complaints complaints){
        int i = complaintsService.insert(
                complaints.getDate(),
                complaints.getPhone(),
                complaints.getName(),
                complaints.getContent(),
                complaints.getDepartment(),
                complaints.getWay());
        return new R().addData("insertCopts",i);
    }
    //修改投诉信息
    @PostMapping("/updateCopts")
    public R updateComplaints(@RequestBody Complaints complaints){
        return new R().addData("complaints",complaintsService.updateByReply(complaints.getResults(),(int)complaints.getId()));
    }
}
